//
//  AfanBaseController.swift
//  weibo
//
//  Created by afan on 16/3/25.
//  Copyright © 2016年 阿范. All rights reserved.
//

import UIKit

class AfanBaseController: UITableViewController {
    
    
    ///用户登录状态
    var userLogin = AfanUserAccountViewModel.sharedInstance.userLogin
    
    override func loadView() {
       AfanUserAccountViewModel.sharedInstance.userLogin ? super.loadView() : setupVisitorView()
    }
    
    func setupVisitorView() {
        
        view = visitorView
        visitorView.delegate = self
        
        if (self is AfanHomeController) {
            visitorView.startRotation()
        } else if (self is AfanMessageController) {
            visitorView.setupVisitor("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
        } else if (self is AfanDiscoverController) {
            visitorView.setupVisitor("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
        } else if (self is AfanProfileController) {
            visitorView.setupVisitor("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
        }

        
        
        
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }

    // MARK: - 懒加载
    /// 自定义的访客视图
    lazy var visitorView: AfanVisitorView = AfanVisitorView()
}
extension AfanBaseController: AfanVisitorViewDelegat{
    func visitorViewDidClickRegisterButton() {
        print("点击了注册")
    }
    func visitroViewDidClickLoginButton() {
        print("点击了登录")
        presentViewController(UINavigationController(rootViewController: AfanOauthViewController()), animated: true, completion: nil)
    }
}